<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="hmg.common.CommonUtils"%>
<%@ page import="hmg.vo.BoardVO"%>
<%@ page import="java.util.List"%>
<%--
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 9. 7.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 9. 7.     Kim hyung soo     최초 생성
--%>
<%
    String searchKeyword = CommonUtils.getDecodedParameter(request.getParameter("searchKeyword"), "");
    String indexType = CommonUtils.getParameter(request.getParameter("indexType"), "");
    String currPage = CommonUtils.getParameter(request.getParameter("page"), "1");

    List<BoardVO> newsList = (List<BoardVO>) request.getAttribute("NewsList");
    Integer totalNews = (Integer) request.getAttribute("TotalNews");

    String[] consonant = {"ㄱ", "ㄴ", "ㄷ", "ㄹ", "ㅁ", "ㅂ", "ㅅ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"};
    String[] alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

    int idxA = newsList.size() / 3;
    int idxB = idxA;
    int idxC = idxA;
    int itemIdx = 0;

    if (newsList.size() % 3 == 1)
        idxA++;
    else if (newsList.size() % 3 == 2) {
        idxA++;
        idxB++;
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>그룹용어사전 | 현대자동차그룹</title>
<meta name="description" content="현대자동차그룹 용어사전 보기" />
<meta name="keywords" content="현대자동차그룹 용어사전, 현대차그룹 용어사전, 그룹용어사전, 용어사전, 사전" />
<%@ include file="/WEB-INF/jsp/web/kor/include/header.jspf" %>
<script type="text/javascript" src="/hmg/js/web/kor/com/jquery.easing.1.3.js"></script>
<script type="text/javascript">
//<![CDATA[
var page = "<%= currPage %>";
var indexType = "<%= indexType %>";

$(document).ready(function(){
    if (page == "")
        page = "1";

    $("#paging").html(getNewsPagingString(<%= totalNews %>, page, 30, 10));
    $("#newsTab" + indexType).addClass("on");
});

function fn_search() {
    var searchKeyword = $("#searchKeyword").val();

    if (searchKeyword == "") {
        alert("검색어를 입력해 주세요.");
        return;
    }

    document.location.href = "./TermDictionaryList.do?searchKeyword=" + escape(encodeURIComponent(searchKeyword)) + "&page=1";
}

function fn_list_by_type(indexType) {
    document.location.href = "./TermDictionaryList.do?indexType=" + indexType + "&page=1";
}

function fn_move_page(pageNo){
    fn_common_move_page(pageNo, location.search, page, 30, <%= totalNews %>, "./TermDictionaryList.do");
}

function fn_view_page(listID) {
    var keyword = escape(encodeURIComponent($("#searchKeyword").val()));

    if (keyword == null || keyword == "")
        document.location.href = "./TermDictionaryView.do?listID=" + listID + "&indexType=<%= indexType %>&page=<%= currPage %>";
    else
        document.location.href = "./TermDictionaryView.do?listID=" + listID + "&searchKeyword=" + keyword + "&page=<%= currPage %>";
}

//]]>
</script>
</head>
<body>
    <!--wrap-->
    <div id="wrap">
        <!-- skip navigation -->
        <div id="skipnavition">
            <a href="#gnb">메뉴바로가기</a><a href="#content">본문바로가기</a>
        </div>
        <!--// skip navigation -->

        <hr />

        <!-- header-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/left.jspf" %>
        <!--//header-->
        <hr />
        <!--container-->
        <div id="container">
            <div class="scroll-pane">
            <!-- 공통 -->
            <div class="subTitle">
                <div class="pageTitle">
                    <h2><img src="/hmg/images/web/kor/title/sch_Dictionary.gif" alt="그룹용어사전" /></h2>
                </div>

                <div class="pageLocation">
                    <ul>
                        <li><a href="/hmg/web/kor/Main.do"><img src="/hmg/images/web/kor/common/location_home.gif" alt="홈"/></a></li>
                        <li class="nowPage"><a href="/hmg/web/kor/sch/trm/TermDictionaryList.do">그룹용어사전</a></li>
                    </ul>
                </div>
            </div>
            <!--//공통-->

            <!--contents-->
            <div id="content">

            <!-- 내용 -->
            <div class="dictionary">

                <div class="dictionary_Box">
                    <div class="dic_Top">
                        <div class="search_Area">
                            <img src="/hmg/images/web/kor/sch/sch_Icon.gif" alt="검색" class="sch_icon"/>
                            <input type="text" title="검색" id="searchKeyword" name="searchKeyword" value="<%= searchKeyword %>" onkeypress="javascript:if (event.keyCode==13) {fn_search();}" />
                            <a href="#" onclick="javascript:fn_search();"><img src="/hmg/images/web/kor/btn/btn_search.gif" alt="검색"  class="btn"/></a>
                            <a href="/hmg/web/kor/sch/trm/TermDictionaryList.do?orderType=1"><img src="/hmg/images/web/kor/btn/btn_recentWord.gif" alt="최신용어" class="btn02"/></a>
                        </div>
                        <dl class="dic">
                            <dt>가나다순 색인</dt>
                            <dd>
                                <ul class="korean">
<%  for (int idx = 0; idx < consonant.length; idx++) { %>
                                    <li id="newsTab<%= idx %>" class="tab01"><a href="javascript:fn_list_by_type(<%= idx %>);"><%= consonant[idx] %></a></li>
<%  } %>
                                </ul>
                            </dd>

                            <dt>알파벳순 색인</dt>
                            <dd>
                                <ul class="english">
<%  for (int idx = 0; idx < alphabet.length; idx++) { %>
                                    <li id="newsTab<%= idx + 14 %>" class="tab14"><a href="javascript:fn_list_by_type(<%= idx + 14 %>);"><%= alphabet[idx] %></a></li>
<%  } %>
                                </ul>
                            </dd>
                        </dl>
                    </div>
                    <div class="dic_Bot">
<%  if (newsList == null || newsList.size() == 0) {
        out.println("   <ul style=\"text-align:center;width:100%;\">검색된 용어가 없습니다.</ul>");
    }
    else {
%>
                        <ul>
<%
        for (int idx = 0; idx < idxA; idx++) {
            BoardVO news = newsList.get(itemIdx);
            String title = "";

            if (news.getTitle() != null)
                title = news.getTitle();

            if (news.getSubtitle() != null)
                title += " [" + news.getSubtitle() + "]";
%>
                            <li><a href="javascript:fn_view_page(<%= news.getListID() %>);"><%= title %></a></li>
<%
            itemIdx++;
        }
%>
                        </ul>

                        <ul>
<%
        for (int idx = 0; idx < idxB; idx++) {
            BoardVO news = newsList.get(itemIdx);
            String title = "";

            if (news.getTitle() != null)
                title = news.getTitle();

            if (news.getSubtitle() != null)
                title += " [" + news.getSubtitle() + "]";
%>
                            <li><a href="javascript:fn_view_page(<%= news.getListID() %>);"><%= title %></a></li>
<%
            itemIdx++;
        }
%>
                        </ul>

                        <ul class="last">
<%
        for (int idx = 0; idx < idxC; idx++) {
            BoardVO news = newsList.get(itemIdx);
            String title = "";

            if (news.getTitle() != null)
                title = news.getTitle();

            if (news.getSubtitle() != null)
                title += " [" + news.getSubtitle() + "]";
%>
                            <li><a href="javascript:fn_view_page(<%= news.getListID() %>);"><%= title %></a></li>
<%
            itemIdx++;
        }
    }
%>
                        </ul>
                    </div>

                </div>

                <div class="gropnews_page">
                    <div class="gropnews_page_left">
                        <ul id="paging"></ul>
                    </div>

                    <div class="gropnews_page_right">
                        <ul>
                            <li><a href="javascript:fn_move_page('prev');"><img src="/hmg/images/web/kor/btn/btn_prev.gif" alt="이전페이지로 이동" /></a></li>
                            <li><a href="javascript:fn_move_page('next');"><img src="/hmg/images/web/kor/btn/btn_next.gif" alt="다음페이지로 이동" /></a></li>
                        </ul>
                    </div>
                </div>

            </div>
            <!--// 내용 -->


            </div>
            <!--//contents-->
            </div>
        </div>
        <!--//container-->

        <hr />

        <!--footer-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/footer.jspf" %>
        <!--//footer-->
        <hr />
        <!--notice-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/notice.jspf" %>
        <!--//notice-->
    </div>
    <!--//wrap-->
</body>
</html>